 import api from '@/api'
// import router, { resetRouter } from '@/router'

const getDefaultState = () => {
  return {
    sideMenus: false,
    showment:false,
    ficationObj:'',// 厂商资质证书状态：// -1：已退回（弹窗资质审核不通过） //  0：待审核（暂无权限资质审核中）//  1：直接进入 //  2：未上传资质（弹窗上传资质） 3：弹窗选择一个账号进入  4：新用户弹注册表单
  }
}
const state = getDefaultState()
const mutations = {

  SET_SIDEMENUS: (state, roles) => {
    state.sideMenus = roles
  },
  SET_SHOWMENT: (state, roles) => {
    state.showment = roles
  },
  SET_FICATIONOBJ: (state, ficationObj) => {
    state.ficationObj = ficationObj
  },
}

const actions = {
  // dynamically modify permissions
  changeSideMenus({ commit }, view) {
    commit('SET_SIDEMENUS', view)
  },
  setShowment({ commit }, view) {
    commit('SET_SHOWMENT', view)
  },
    // 获取商家资质证书状态
    getFicationStatus({ commit }, data) {
      const imListId = data
      return new Promise((resolve, reject) => {
        api.login.getUserAuthority().then(response => {
          const data = response.data
          // 证书状态： -1 已退回 0 待审核 1 已通过 2 未上传 3 已过期
          commit('SET_FICATIONOBJ', data)
          resolve(data)
        }).catch(error => {
          reject(error)
        })
      })
    },
}

export default {
  state,
  mutations,
  actions
}
